//
//  UIImage+XMGExtention.m
//  12-图片的拉伸问题
//
//  Created by xiaomage on 16/1/23.
//  Copyright © 2016年 小码哥. All rights reserved.
//

#import "UIImage+XMGExtention.h"

@implementation UIImage (XMGExtention)
+(instancetype)resizableImageWithImageName:(NSString *)imageName{
    // 创建图片对象
    UIImage *image = [UIImage imageNamed:imageName];
    // 图片的尺寸
    CGFloat imageWidth = image.size.width * 0.5;
    CGFloat imageHeight = image.size.height * 0.5;
    //方法一: strechableImageWith...
    return [image stretchableImageWithLeftCapWidth:imageWidth topCapHeight:imageHeight];
    
      //方法二: resizzbleImageWith...
        //UIImageResizingModeTile,  以平铺的方式进行拉伸
        //UIImageResizingModeStretch, 直接拉伸平铺
    
    /*
   UIEdgeInsets edgeInsets = UIEdgeInsetsMake(image.size.height * 0.5, image.size.width * 0.5, image.size.height * 0.5 -1, image.size.width * 0.5 -1);
   return [image resizableImageWithCapInsets:edgeInsets resizingMode:UIImageResizingModeTile];
     
    */
}
@end
